import com.aoyebobi.redis.DemoRedisApplication;
import com.aoyebobi.redis.util.RedisUtil;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

/**
 * @Description
 * @Author aoyebobi
 * @Date 2024-08-27
 */
@SpringBootTest(classes = DemoRedisApplication.class)
public class Demo {

    @Resource
    private RedisUtil redisUtil;

    @Test
    public void testString(){
        redisUtil.setValue("key1","value1");
        System.out.println(redisUtil.getValue("key1"));
        redisUtil.deleteValue("key1");
        System.out.println(redisUtil.getValue("key1"));
    }

    @Test
    public void testHash(){
        redisUtil.setHash("hashKey1","key1","value1");
        System.out.println(redisUtil.getHashValue("hashKey1","key1"));
        Map<Object,Object> map = new HashMap<>();
        map.put("key2","value2");
        map.put("key3","value3");
        redisUtil.setHash("hashKey1",map);
        System.out.println(redisUtil.getHashKeys("hashKey1"));
        redisUtil.deleteHash("hashKey1","key1");
        System.out.println(redisUtil.getHashValue("hashKey1","key1"));
    }

}
